package model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

@Entity
@Table(name = "USUARIO_ACAO")
@XmlRootElement
public class UsuarioAcao implements java.io.Serializable {

    private long usaCodigo;
    private Usuario usuario;
    private Acao acao;
    private Boolean usaPermissao;

    public UsuarioAcao() {
    }

    public UsuarioAcao(long usaCodigo, Usuario usuario, Acao acao, Boolean usaPermissao) {
        this.usaCodigo = usaCodigo;
        this.usuario = usuario;
        this.acao = acao;
        this.usaPermissao = usaPermissao;
    }

    @Id
    @SequenceGenerator(name = "seqUsuarioAcao", sequenceName = "SEQ_USUARIO_ACAO")
    @Column(name = "USA_CODIGO", unique = true, nullable = false, precision = 10, scale = 0)
    public long getUsaCodigo() {
        return this.usaCodigo;
    }

    public void setUsaCodigo(long usaCodigo) {
        this.usaCodigo = usaCodigo;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "USU_CODIGO")
    public Usuario getUsuario() {
        return this.usuario;
    }

    public void setUsuario(Usuario usuario) {
        this.usuario = usuario;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "ACAO_CODIGO")
    public Acao getAcao() {
        return this.acao;
    }

    public void setAcao(Acao acao) {
        this.acao = acao;
    }

    @Column(name = "USA_PERMISSAO", length = 1)
    public Boolean getUsaPermissao() {
        return usaPermissao;
    }

    public void setUsaPermissao(Boolean usaPermissao) {
        this.usaPermissao = usaPermissao;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 79 * hash + (int) (this.usaCodigo ^ (this.usaCodigo >>> 32));
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final UsuarioAcao other = (UsuarioAcao) obj;
        if (this.usaCodigo != other.usaCodigo) {
            return false;
        }
        return true;
    }
}
